perm filename FILTER.SAI[PIC,HE] blob
sn#419571 filedate 1979-02-22 generic text, type C, neo UTF8
COMMENT ā VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 entry filter
C00005 ENDMK
Cā;
entry filter;
begin
comment Filtering of a huge .seg (and .sseg) file to
retain only longer segments. This program also preserves
seg to sseg mappings.
January 24, 1979
K Ramesh Babu
Endcomment;
require "<babu>define.sai" source!file;
require "<babu>seg.dcl" source!file;
require "<babu>sseg.dcl" source!file;
internal simple procedure filter;
begin "filter"
integer output, ssegfile;
integer c, k, ss, oss, kss; real minl;
output := openfile(picture & ".seg1","wc");
swdptr(output,hdrl); wrecsz := rrecsz;
Print("This filter will pass only those that are >, not >=, the minimum length.",crlf);
c := 0; k := 0; rprmpt("min length",minl);
ss := 0; oss := 0; kss := 0;
while c < segno do
begin
sgin; c := c + 1; ss := seg:family[pseg];
if seg:length[pseg] > minl then
begin
k := k + 1; seg:name[pseg] := k;
end;
if ss neq oss then kss := kss + 1;
seg:pred[pseg] := 0; seg:succ[pseg] := 0;
seg:fork[pseg] := 0; seg:family[pseg] := kss;
arryout(output,seg:name[pseg],wrecsz);
oss := ss;
end;
sghdr[34] := k; sghdr[35] := kss;
swdptr(output,0); arryout(output,sghdr[0],hdrl);
cfile(output);
end "filter" ;